package com.owncloud.android.ui;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.fri.libfriapkrecord.read.SignRecordTools;
import com.owncloud.android.R;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

public class About extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.community_layout);
        final TextView tv = (TextView) findViewById(R.id.tv_channel);
        //系统环境下APK路径
        final String apkPath = getNativeApkPath(About.this.getApplicationContext());
        //读取备案号
        String recordNum = SignRecordTools.readNumbers(apkPath);
        tv.setText("全国注册备案号："+recordNum);
        //测试读取备案号
    }

    //获取系统内APK文件路径
    public static String getNativeApkPath(@NonNull final Context context) {
        String apkPath = null;
        try {
            final ApplicationInfo applicationInfo = context.getApplicationInfo();
            if (applicationInfo == null) {
                return null;
            }
            apkPath = applicationInfo.sourceDir;
        } catch (Throwable e) {
        }
        return apkPath;
    }
}
